<?php
	// +----------------------------------------------------------------------
	// | 商品简单分类
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------
	namespace app\model\store;

	use app\model\file\Image;

	class GoodCategory extends Common
	{


		// 类型转换
		protected $type = [
			'attribute_groups' => 'array'
		];


		public function goods()
		{
			return $this->hasMany(Good::class)->where('status','>',-2);
		}

		public function parent()
		{
			return $this->belongsTo(GoodCategory::class, 'parent_id')->where('status',1);;
		}

		public function cover()
		{
			return $this->belongsTo(Image::class, 'cover_id');
		}
		public function children()
		{
			return $this->hasMany(GoodCategory::class, 'parent_id')->where('status',1);
		}
	}
